<template>
  <div>
    <div>
      <!-- 内部判断v-model是数组, 绑定value值, 非数组绑定checked属性 -->
      <input type="checkbox" v-model="hobby" value="科幻" /><span>科幻</span>
      <input type="checkbox" v-model="hobby" value="喜剧" /><span>喜剧</span>
      <input type="checkbox" v-model="hobby" value="动漫" /><span>动漫</span>
      <input type="checkbox" v-model="hobby" value="冒险" /><span>冒险</span>
      <input type="checkbox" v-model="hobby" value="科技" /><span>科技</span>
      <input type="checkbox" v-model="hobby" value="军事" /><span>军事</span>
      <input type="checkbox" v-model="hobby" value="娱乐" /><span>娱乐</span>
      <input type="checkbox" v-model="hobby" value="奇闻" /><span>奇闻</span>
    </div>

    <ul>
      <!-- 需要获取复选框里的值, index和 val都声明 -->
      <li v-for="(val, index) in hobby" :key="index">{{ val }}</li>
    </ul>
  </div>
</template>



<script>
export default {
  data() {
    return {
      hobby: [],
    };
  },
  methods: {},
};
</script>


<style>
</style>